package com.kgame5.xtank3d.model.cart.fsms.move {
import kgame5.kmath.MathDG;

import com.kgame5.xtank3d.GameEnum;
import com.kgame5.xtank3d.model.tank.fsms.TankState;
import com.kgame5.xtank3d.vo.MyTankVO;

public class ThinkMovState extends TankState{
	
	//__________________Propetty__________________
	
	//______________________Method___________________
	public  function ThinkMovState(vo:MyTankVO){
		super(GameEnum.STATE_EM_THINK_MOVE, vo);
		
	}
	
	//进入状态
	 override public function  enter(info:Object=null):void{
		v.x=0;
		v.z=0;
		
		goonThink();
		
		tankVO.bMove=false;
	}

	//执行状态
	 override public function  update():void{
		 if(timer.isOK()){//思考完毕，开始行动
			 //漫游，猎杀，继续思考
			 var a:int=MathDG.random(0, 100);
			 if(a<tankVO.ai.mov_action_rate_wander){
				 //进入漫游状态
				 gotoWander();
			 }else if(a<tankVO.ai.mov_action_rate_hunt+tankVO.ai.mov_action_rate_wander){
				//进入猎杀状态
				gotoHunt();
			}else{
				//继续思考
				goonThink();
			}
		 }
	}
	
	//退出状态
	override public function  exit():void{
		tankVO.bMove=true;
	}

	//进入漫游
	private function gotoWander():void{
		//T.p("进入漫游");
		fsm.SwitchState(GameEnum.STATE_EM_WANDER_MOVE, null);
	}
	
	//进入猎杀
	private function gotoHunt():void{
		//T.p("进入猎杀");
		fsm.SwitchState(GameEnum.STATE_EM_HUNT_MOVE, null);
	}
	
	//继续思考
	private function goonThink():void{
		//T.p("继续思考");
		var interval:int=MathDG.random(tankVO.ai.mov_think_interval_min, tankVO.ai.mov_think_interval_max);
		timer.start(interval);
	}
}//end of class
}
